//package com.example.demo2.controller;
//
//
//import cn.hutool.core.date.DateUtil;
//import com.example.demo2.common.Result;
//import com.example.demo2.entity.Order;
//import com.example.demo2.service.OrderService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.*;
//
//import java.util.Date;
//
//@RestController
//@RequestMapping("/order")
//public class OrderController2 {
//    @Autowired
//    private OrderService orderService;
//    @PostMapping("/add")
//    public Result save(@RequestBody Order order) {
//        order.setCreateTime(DateUtil.toLocalDateTime(new Date()));
//        order.setState("审核中");
//        boolean save = orderService.save(order);
//        if(save){
//            return Result.success("200","订单添加成功",save);
//        }else {
//            return Result.error("订单添加失败","-1");
//        }
//    }
//    @PostMapping("/cancel")
//    public Result cancel(@RequestParam Integer id) {
//        boolean save = orderService.removeById(id);
//        if(save){
//            return Result.success("200","订单取消成功",save);
//        }else {
//            return Result.error("订单取消失败","-1");
//        }
//    }
////    @PostMapping("/getOrderByPage")
////    public Result getOrderByPage(@RequestBody OrderDTO orderDTO){
////        LambdaQueryWrapper<Order> lqw = new LambdaQueryWrapper<>();
////        Page<Order> ipage = new Page<>(orderDTO.getPage(), orderDTO.getLimit());
////        Page<Order> page = orderService.page(ipage, lqw);
////        return Result.success(page);
////    }
////    @PostMapping("/examineOrderRight")
////    public Result examineOrder(@RequestBody Integer id){
////        LambdaQueryWrapper<Order> lqw = new LambdaQueryWrapper<>();
////        lqw.eq(Order::getId,id);
////        Order order = orderService.getOne(lqw);
////        if(order == null){
////            return Result.error("订单不存在","-1");
////        }
////        order.setState("审核通过");
////        orderService.updateById(order);
////        return Result.success(order);
////    }
////    @PostMapping("/examineOrderError")
////    public Result examineOrderError(@RequestBody Integer id){
////        LambdaQueryWrapper<Order> lqw = new LambdaQueryWrapper<>();
////        lqw.eq(Order::getId,id);
////        Order order = orderService.getOne(lqw);
////        if(order == null){
////            return Result.error("订单不存在","-1");
////        }
////        order.setState("审核不通过");
////        orderService.updateById(order);
////        return Result.success(order);
////    }
////    @PostMapping("/examineOrderFinish")
////    public Result examineOrderFinish(@RequestBody Integer id){
////        LambdaQueryWrapper<Order> lqw = new LambdaQueryWrapper<>();
////        lqw.eq(Order::getId,id);
////        Order order = orderService.getOne(lqw);
////        if(order == null){
////            return Result.error("订单不存在","-1");
////        }
////        order.setState("订单已完成");
////        orderService.updateById(order);
////        return Result.success(order);
////    }
//}
